package com.activity.cycle;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.Button;

/**
 * Created by lgs on 2018/4/4.
 */

public class NewActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_new);
        Log.i("activityLog", "onCreate_new");
        onViewClick();
    }

    @Override
    protected void onRestart() {
        super.onRestart();
        Log.i("activityLog", "onRestart_new");
    }

    @Override
    protected void onStart() {
        super.onStart();
        Log.i("activityLog", "onStart_new");
    }

    @Override
    protected void onResume() {
        super.onResume();
        Log.i("activityLog", "onResume_new");
    }

    @Override
    protected void onPause() {
        super.onPause();
        Log.i("activityLog", "onPause_new");
    }

    @Override
    protected void onStop() {
        super.onStop();
        Log.i("activityLog", "onStop_new");
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        Log.i("activityLog", "onDestroy_new");
    }

    public void onViewClick() {
        Button btn = findViewById(R.id.btn_go_main);
        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                startActivity(new Intent(NewActivity.this, MainActivity.class));
//                finish();
            }
        });
        Button btnFinish = findViewById(R.id.btn_finish);
        btnFinish.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                Intent intent = new Intent();
                intent.putExtra("data", "约吗");
                setResult(1, intent);
                finish();
            }
        });
    }
}
